cmake_minimum_required(VERSION 3.8)
project(stmros)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# 查找依赖
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rcpputils REQUIRED)
find_package(stmros_msgs REQUIRED)
find_package(libstmconn REQUIRED)

# 包含头文件目录
include_directories(
  include
  ${libstmconn_INCLUDE_DIRS}
)

# 创建插件库
add_library(stmros_plugins SHARED
  src/plugins/dummy_plugin.cpp
)

ament_target_dependencies(stmros_plugins
  rclcpp
  rclcpp_components
  rcpputils
  pluginlib
  stmros_msgs
  libstmconn
)

pluginlib_export_plugin_description_file(stmros stmros_plugins.xml)

# 注册插件组件
rclcpp_components_register_nodes(stmros_plugins "stmros::std_plugins::DummyPlugin")

# 创建可执行文件
add_executable(stmros_node
  src/stmros.cpp
  src/stmros_node.cpp
)

# 添加依赖
ament_target_dependencies(stmros_node
  rclcpp
  rclcpp_components
  stmros_msgs
  libstmconn
)

target_link_libraries(stmros_node stmros_plugins)

# 安装可执行文件
install(TARGETS stmros_node
  DESTINATION lib/${PROJECT_NAME}
)

# 安装launch文件
install(DIRECTORY launch/
  DESTINATION share/${PROJECT_NAME}/launch
)

ament_package()